<template>
  <div id="repmember">
    <div class="empty" v-if="!isEmpty">
      <img src="../../../assets/wubuhuoyuan.png" alt="">
      <p>暂无补货员</p>
    </div>
    <div class="members" v-if="isEmpty">
      <router-link
      :to="{name: 'Repmessage'}"
      tag="div"
      class="member">
        <div class="left">
          <div class="tou" :style="{background: colors}"></div>
          <div class="mess">
            <p class="name">曲飞</p>
            <span>射频卡补货</span>
          </div>
        </div>
        <div class="right">
          <p class="noAdopt">审核中...</p>
        </div>
      </router-link>
      <router-link
      :to="{name: 'Repmessage'}"
      tag="div"
      class="member">
        <div class="left">
          <div class="tou" :style="{background: colors}"></div>
          <div class="mess">
            <p class="name">陈一宇</p>
            <span>扫码补货</span>
          </div>
        </div>
        <div class="right">
          <p class="adopt">已通过</p>
        </div>
      </router-link>
      <router-link
      :to="{name: 'Repmessage'}"
      tag="div"
      class="member">
        <div class="left">
          <div class="tou" :style="{background: colors}"></div>
          <div class="mess">
            <p class="name">刘逸分</p>
            <span>扫码补货和射频卡补货</span>
          </div>
        </div>
        <div class="right">
          <p class="adopt">已通过</p>
        </div>
      </router-link>
    </div>
    <div class="bottom" @click="addNumbers">
      <div>
        <img src="../../../assets/tianjia.png" alt="">
        <span>添加补货员</span>
      </div>
    </div>
    <div class="tishi" v-if="isTips">补货员添加成功</div>
  </div>
</template>

<script>
export default {
  name: 'Repmember',
  data () {
    return {
      colors: 'red',
      isEmpty: true,
      isTips: false
    }
  },
  created () {
    document.title = '补货员管理'
    var chars = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F']
    function generateMixed (n) {
      var res = '#'
      var id
      for (var i = 0; i < n; i++) {
        id = Math.floor(Math.random() * 16)
        res += chars[id]
      }
      // console.log(id, res)
      return res
    }
    var mm = generateMixed(6)
    var bb = generateMixed(6)
    var cc = generateMixed(6)
    console.log(mm, bb, cc)
    this.colors = generateMixed(6)
  },
  mounted () {
    let name = document.getElementsByClassName('name')
    let nameLength = name.length
    let tou = document.getElementsByClassName('tou')
    let touLength = tou.length
    for (var i = 0; i < nameLength; i++) {
      for (var j = i; j < touLength; j++) {
        tou[j].innerText = name[i].innerText.slice(0, 1)
      }
    }
  },
  methods: {
    addNumbers () {
      this.$router.push({name: 'Createmeb'})
    }
  }
}
</script>

<style lang='scss' scoped>
#repmember{
  width: 100%;
  height: 100%;
  overflow-x: hidden;
  position: relative;
  .empty{
    margin-top: 37.86vw;
    display: flex;
    flex-direction: column;
    align-items: center;
    img{
      width: 18.13vw;
      height: 30.66vw;
    }
    p{
      font-size: 4.73vw;
      font-family:SourceHanSansCN-Regular;
      font-weight:400;
      color:rgba(134,134,134,1);
    }
  }
  .members{
    background-color: #fff;
    padding: 0 3.46vw;
    .member{
      height: 21.06vw;
      display: flex;
      align-items: center;
      justify-content: space-between;
      .left{
        display: flex;
        .tou{
          width: 13.06vw;
          height: 13.06vw;
          background-color: #0f0;
          border-radius: 7vw;
          text-align: center;
          line-height: 13.06vw;
          font-size: 5.33vw;
          font-family: SourceHanSansCN-Regular;
          font-weight: 400;
          color:rgba(255,255,255,1);
          margin-right: 4vw;
        }
        .mess{
          p{
            font-size: 4.8vw;
            font-family: SourceHanSansCN-Regular;
            font-weight: 400;
            color: rgba(22,22,22,1);
            line-height: 7.2vw;
          }
          span{
            font-size: 3.73vw;
            font-family: SourceHanSansCN-Regular;
            font-weight: 400;
            color: rgba(168,168,168,1);
            line-height: 5.6vw;
          }
        }
      }
      .right{
        p{
          font-size: 3.73vw;
          font-family:SourceHanSansCN-Regular;
          font-weight:400;
          &.noAdopt{
            color:rgba(255,137,0,1);
          }
          &.adopt{
            color:rgba(10,109,255,1);
          }
        }
      }
    }
  }
  .bottom{
    width: 100%;
    height: 14.66vw;
    background-color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    bottom: 0;
    div{
      display: flex;
      img{
        width: 4.53vw;
        height: 4.53vw;
        margin-right: 2.66vw;
      }
      span{
        font-size: 4.53vw;
        font-family:SourceHanSansCN-Normal;
        font-weight:400;
        color:rgba(10,109,255,1);
      }
    }
  }
  .tishi{
    width: 84vw;
    height: 10.4vw;
    background:rgba(0,0,0,1);
    border-radius:4px;
    opacity:0.8;
    text-align: center;
    line-height: 10.4vw;
    font-size: 4.26vw;
    font-family:SourceHanSansCN-Regular;
    font-weight:400;
    color:rgba(255,255,255,1);
    position: absolute;
    top: 74vw;
    left: 8vw;
    z-index: 2;
  }
}
</style>
